﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace 图书管理系统
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        }

        private void button_Copy_Click(object sender, RoutedEventArgs e)
        {
            RegWin win = new RegWin();
            win.Show();
        }

        private static UserInfoTabBll bll = new UserInfoTabBll();

        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (txtID.Text.Trim()==""||txtPwd.Password.Trim()=="")
            {
                MessageBox.Show("请输入用户名密码!","温馨提示",MessageBoxButton.OK);
            }
            UserInfo model = new UserInfo();
            model.ID = txtID.Text.Trim();
            model.Password = txtPwd.Password.Trim();
            bool b=bll.Login(model);
            if (b)
            {
                MainWin win = new MainWin();
                win.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名密码错误!","温馨提示",MessageBoxButton.OK,MessageBoxImage.Asterisk);
            }
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
